#define _CRT_SECURE_NO_WARNINGS 1

#include "stack.h"


void InitStack(Stack* s)
{
	s->top = -1;
}

void DestroyStack(Stack* s);

void ClearStack(Stack* s)
{
	s->top = -1;
}

int StackEmpty(Stack* s)
{
	return s->top < 0;
}

Status GetTop(Stack* s, ElemType* e)
{
	if (s->top < 0) return ERROR;
	*e = s->data[s->top];
	return OK;
}

Status Push(Stack* s, ElemType e)
{
	if (s->top == MAXSIZE - 1)
		return ERROR;
	s->top++;
	s->data[s->top] = e;
	return OK;
}

Status Pop(Stack* s, ElemType* e)
{
	if (s->top < 0) return ERROR;
	*e = s->data[s->top];
	s->top--;
	return OK;
}

int StackLength(Stack* s)
{
	return s->top + 1;
}